﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Model;
using BLL;
using System.Data;

namespace WebApplication2
{
    /// <summary>
    /// RcarpoolingDeails 的摘要说明
    /// </summary>
    public class RcarpoolingDeails :BasePage,IHttpHandler,System.Web.SessionState.IReadOnlySessionState
    {

        public new void ProcessRequest(HttpContext context)
        {
            

            string change=context.Request["change"];

            switch (change)
            {
                case "1":
                    Show(context);
                    break;
                case "2":
                    JoinAL(context);
                    break;
            }

           
        }

        public void JoinAL(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            ALTableInfo al = new ALTableInfo(int.Parse(context.Request["LongID"]), LoginUser.UserID);
            if (ALTableInfoBLL.ALTableInfoAdd(al))
            {
                context.Response.Write(1);
            }
            else
            {
                context.Response.Write(2);
            }

        }


        /// <summary>
        /// 显示长途拼单详细界面
        /// </summary>
        /// <param name="context">窗体对象</param>
        public void Show(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string LongID = "2";
            DataTable dt = LongCarBLL.SelectLongCar(int.Parse(LongID));
            string str = "";
            if (dt != null)
            {
                str += "{\"LongID\":\"" + dt.Rows[0]["LongID"] + "\",\"LGoCity\":\"" + dt.Rows[0]["LgoCity"] + "\",\"LDesitination\":\"" + dt.Rows[0]["LDesitination"] + "\"" +
                    ",\"LGoDate\":\"" + dt.Rows[0]["LGoDate"] + "\",\"LCarType\":\"" + dt.Rows[0]["LCarType"] + "\",\"LPPeople\":\"" + dt.Rows[0]["LPPeople"] + "\"" +
                    ",\"LContain\":\"" + dt.Rows[0]["LContain"] + "\",\"LCost\":\"" + dt.Rows[0]["LCost"] + "\",\"UserID\":\"" + dt.Rows[0]["UserID"] + "\"" +
                    ",\"LCWord\":\"" + dt.Rows[0]["LCWord"] + "\",\"LBPeople\":\"" + dt.Rows[0]["LBPeople"] + "\",\"LPTime\":\"" + dt.Rows[0]["LPTime"] + "\"" +
                    ",\"LStatus\":\"" + dt.Rows[0]["LStatus"] + "\",\"LPType\":\"" + dt.Rows[0]["LPType"] + "\",\"BMMan\":\"" + dt.Rows[0]["BMMan"] + "\",\"SQMan\":\"" + dt.Rows[0]["SQMan"] + "\"}";
                context.Response.Write(str);
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}